package com.heima.kafka.controller;

import com.alibaba.fastjson.JSON;
import com.heima.kafka.entity.Student;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.kafka.core.KafkaTemplate;
import org.springframework.util.concurrent.ListenableFuture;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;


/**
 * @Description TODO
 * @Author bo.li
 * @Date 2022/11/13 14:42
 * @Version 1.0
 */
@RestController
public class SendController {

    @Autowired
    private KafkaTemplate kafkaTemplate;

    @GetMapping("/send")
    public String send(String msg){
        Student student = new Student();
        student.setName(msg);
        student.setAge(22);
        kafkaTemplate.send("order-create", JSON.toJSONString(student));
        return "OK";
    }
}